<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('银行数据接收列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li class="select-time">
                                <label>接收时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginReceiveDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endReceiveDate]"/>
                            </li>
                            <li>
								数据类型：<select name="params[sjlx]" >
									<option value="">所有</option>
									<option value="0">银行上传</option>
									<option value="1">平台上传</option>
								</select>
							</li>
                            <li>
								代理银行：<select name="yhbm" >
									<option value="">所有银行</option>
									<option th:each="bk : ${yhlist}" th:text="${bk.yhmc}" th:value="${bk.yhbm}"></option>
								</select>
							</li>
                            <li>
								是否接收：<select name="sfjs" >
									<option value="">所有</option>
									<option value="0" selected="selected">未接收</option>
									<option value="1">已接收</option>
								</select>
							</li>
                            <li>
                                <label>金额：</label>
                                <input type="text" name="je"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                
                <a class="btn btn-danger single disabled" onclick="remove()" shiro:hasPermission="system:yhsjjs:remove">
                    <i class="fa fa-remove"></i> 清除
                </a>
                <a class="btn btn-success single disabled" onclick="accept()" shiro:hasPermission="system:yhsjjs:accept">
                    <i class="fa fa-check"></i> 接收
                </a>
                <a class="btn btn-success single disabled" onclick="unaccept()" shiro:hasPermission="system:yhsjjs:unaccept">
                    <i class="fa fa-check"></i> 撤销接收
                </a>
                <a class="btn btn-success single disabled" onclick="mxlist()" shiro:hasPermission="system:yhsjjs:mxlist">
                    <i class="fa fa-search"></i> 明细
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:yhsjjs:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var acceptFlag = [[${@permission.hasPermi('system:yhsjjs:accept')}]];
        var unacceptFlag = [[${@permission.hasPermi('system:yhsjjs:unaccept')}]];
        var mxlistFlag = [[${@permission.hasPermi('system:yhsjjs:mxlist')}]];
        var removeFlag = [[${@permission.hasPermi('system:yhsjjs:remove')}]];
        var pzlistFlag = [[${@permission.hasPermi('system:yhsjjs:pzlist')}]];
        var prefix = ctx + "system/yhsjjs";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "银行数据接收",
                showFooter: true,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'lsh',
                    title: '流水号',
                    visible: false
                },
                {
                    field: 'jsn',
                    title: '接收年'
                },
                {
                    field: 'jsy',
                    title: '接收月'
                },
                {
                    field: 'jsr',
                    title: '接收日'
                },
                {
                    field: 'sfjs',
                    title: '是否接收',
		        	formatter: function (value, row, index) {
		        		return statusTools(row);
		        	}
                },
                {
                    field: 'yhbm',
                    title: '银行编码'
                },
                {
                    field: 'yhmc',
                    title: '银行名称'
                },
                {
                    field: 'yhzh',
                    title: '银行账号'
                },
                {
                    field: 'je',
                    title: '金额',
                    align: 'right', 
                    formatter: function(value, row, index) {
   				        return number_format(row.je,2);
   				    },
   				    footerFormatter:function (value) {
   				    	var sumJe = 0;
   				        for (var i in value) {
   				        	sumJe += parseFloat(value[i].je);
   				        }
   				        return "总金额：" + number_format(sumJe,2);
   				    }
                },
                {
                    field: 'kjpz',
                    title: '会计凭证编号'
                },
                {
                    field: 'pztxh',
                    title: '凭证头序号'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.sfjs == 1) {
	                        actions.push('<a class="btn btn-success btn-xs ' + mxlistFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.lsh + '\')"><i class="fa fa-edit"></i>明细</a> ');
	                        actions.push('<a class="btn btn-info btn-xs ' + pzlistFlag + '" href="javascript:void(0)" onclick="pzlist(\'' + row.pztxh + '\')"><i class="fa fa-search"></i>查看凭证</a> ');
                        }else{
	                        actions.push('<a class="btn btn-success btn-xs ' + acceptFlag + '" href="javascript:void(0)" onclick="acceptData(\'' + row.lsh + '\')"><i class="fa fa-edit"></i>接收</a> ');
	                        actions.push('<a class="btn btn-info btn-xs ' + mxlistFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.lsh + '\')"><i class="fa fa-search"></i>明细</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        /*字典列表-详细*/
		function detail(lsh) {
		    var url = prefix + '/detail/' + lsh;
		    $.modal.openFull("明细数据", url);
		}
        
		/* 用户状态显示 */
		function statusTools(row) {
		    if (row.sfjs == 1) {
    			return '<i class=\"fa fa-check text-info fa-2x\" ></i> ';
    		} else {
    			return '<i class=\"fa fa-times text-info fa-2x\"></i> ';
    		}
		}
		/* 用户管理启用 */
		function accept() {
			var lsh = $.table.selectColumns('lsh');
			$.modal.confirm("确认要接收此数据吗？", function() {
				$.operate.post(prefix + "/acceptData", { "lsh": lsh});
		    })
		}
		/* 用户管理启用 */
		function unaccept() {
			var pztxh = $.table.selectColumns('pztxh');
			var sfjs = $.table.selectColumns('sfjs');
			var kjpz = $.table.selectColumns('kjpz');
			if (sfjs[0]!=1){
				$.modal.alertWarning("此记录未接收不以能撤销");
			}
			$.modal.confirm("确认要撤销接收["+kjpz[0]+"]对应的数据吗？", function() {
				debugger;
				$.operate.post(prefix + "/unacceptData", { "pztxh": pztxh[0]});
		    })
		}
		 /*字典列表-详细*/
		function mxlist() {
			var lsh = $.table.selectColumns('lsh');
		    var url = prefix + '/detail/' + lsh;
		    $.modal.openFull("明细数据", url);
		}
		 
		function remove() {
			var lsh = $.table.selectColumns('lsh');
			$.modal.confirm("确认要删除此数据吗？", function() {
				debugger;
				 var data = {"lsh": lsh[0]};
				$.operate.post(prefix + "/remove", data);
		    })
		} 
		
		/* 用户管理启用 */
		function acceptData(lsh) {
			$.modal.confirm("确认要接收此数据吗？", function() {
				$.operate.post(prefix + "/acceptData", { "lsh": lsh});
		    })
		}
		
		function pzlist(pztxh) {
		    var url = ctx + 'system/pzto/pzlist/' + pztxh;
		    $.modal.openFull("查看凭证", url, '800', '540');
		}
    </script>
</body>
</html>